package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.BigClient;
import cn.wolfcode.crm.mapper.BigClientMapper;
import cn.wolfcode.crm.query.BigClientObject;
import cn.wolfcode.crm.service.IBigClientService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BigClientServiceImpl implements IBigClientService {

    @Autowired
    private BigClientMapper mapper;


    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);
    }

    public void save(BigClient entity) {
        mapper.insert(entity);
    }

    public void update(BigClient entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public BigClient get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<?> list() {
        return mapper.selectAll();
    }

    public PageResult query(BigClientObject qo) {
        int total = mapper.queryForCount(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<BigClient> list = mapper.queryForList(qo);
        return new PageResult(total,list);
    }

    public void sign(Long id) {
        mapper.sign(id);
    }
}
